package com.example.videoweb.config;

import org.springframework.context.annotation.Configuration;
import org.springframework.web.servlet.config.annotation.ResourceHandlerRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;

@Configuration
public class FileConfig implements WebMvcConfigurer {  //用于前端获取后端静态资源

    @Override
    public void addResourceHandlers(ResourceHandlerRegistry registry) {
        //获取前端用户头像地址
        registry.addResourceHandler("/avatarImages/**").addResourceLocations(
                "file:"+System.getProperty("user.dir")+System.getProperty("file.separator")
                    +"avatarImages"+System.getProperty("file.separator")
        );
        registry.addResourceHandler("/videoPic/**").addResourceLocations(
                "file:"+System.getProperty("user.dir")+System.getProperty("file.separator")
                    +"videoPic"+System.getProperty("file.separator")
        );
        registry.addResourceHandler("/video/**").addResourceLocations(
                "file:"+System.getProperty("user.dir")+System.getProperty("file.separator")
                    +"video"+System.getProperty("file.separator")
        );
    }
}
